package com.boarsoft.log.core;

import java.util.concurrent.atomic.AtomicBoolean;

import org.slf4j.Logger;

public interface SampleLogger extends Logger {
	public static final int SAMPLING_NONE = 0;
	public static final int SAMPLING_NORMAL = 1;
	public static final int SAMPLING_REALTIME = 2;

	/** 日志输出的上下级关系 */
	public static final String MDC_TRACES = "log.traces";
	/** 日志采样过滤用关键字 */
	public static final String MDC_SAMPLE = "log.sample";
	/** 日志采集后的发送目标 */
	public static final String MDC_TARGET = "log.target";
	/** 调用发生时间 */
	public static final String MDC_TIME = "log.time";

	/** 全局日志监控开关 */
	public static AtomicBoolean sampling = new AtomicBoolean(false);

	/**
	 * 表示从“现在”开始“监控”某种日志
	 * 
	 * @param key
	 *            eg: flowId
	 * @param ratio
	 */
	void notice(String key, Integer ratio);

	/**
	 * 取消日志“监控”
	 * 
	 * @param key
	 *            eg: flowId
	 */
	void ignore(String key);

	/**
	 * 判断是否需要监控这个KEY
	 * 
	 * @param key
	 *            eg: flowId
	 * @return
	 */
	boolean isSampling(String key);

	/**
	 * 
	 * @param key
	 * @return
	 */
	Integer getRatio(String key);
}
